/**
 * PlayService.java
 *
 *	
 */
package com.ghc.androidexample.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

/**
 * 
 */
public class PlayService {
	private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;

	public static boolean checkPlayServices(Activity activity) {
		int resultCode = GooglePlayServicesUtil
				.isGooglePlayServicesAvailable(activity);
		if (resultCode != ConnectionResult.SUCCESS) {
			if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
				GooglePlayServicesUtil.getErrorDialog(resultCode, activity,
						PLAY_SERVICES_RESOLUTION_REQUEST).show();
			} else {
				Log.i(PlayService.class.getSimpleName(),
						"This device is not supported.");
				AlertDialog.Builder builder = new AlertDialog.Builder(activity);
				builder.setMessage("No Google Play Service");
				builder.show();
			}
			return false;
		}
		return true;
	}
}
